package com.sdehua.wear.controller;

import com.sdehua.wear.entity.Goods;
import com.sdehua.wear.service.GoodsService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Goods)表控制层
 *
 * @author makejava
 * @since 2021-12-31 15:28:48
 */
@RestController
@RequestMapping("goods")
@CrossOrigin
public class GoodsController {
    /**
     * 服务对象
     */
    @Resource
    private GoodsService goodsService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public Goods selectOne(Integer id) {
        return this.goodsService.queryById(id);
    }

    @GetMapping("queryAll")
    public List<Goods> queryAll(){
        return this.goodsService.queryAll();
    }

    @GetMapping("queryByTypeId")
    public List<Goods> queryByTypeId(int id){
        return this.goodsService.queryByTypeId(id);
    }

    @RequestMapping("queryByCondition")
    public List<Goods> queryByCondition(String sizeConditions,String materialConditions,String styleConditions,String typeId){
        List<Goods> list = goodsService.queryByCondition(typeId,sizeConditions,materialConditions,styleConditions);
        return list;
    }

}